<?php
namespace Home\Controller;
use Think\Controller;
class JobController extends Controller {
              //展示职业
       	//http://localhost:18181/NongGuoGuo/index.php/home/job/showjob
       public function showjob(){
              $profession=M("Profession");
              $data=$profession->select();
              
              if ($data) {
                     $this->ajaxReturn(array("code"=>200,"data"=>$data),"JSON");
              }else{
                     $this->ajaxReturn(array("code"=>500,"data"=>NULL),"JSON");
              }
       }
       //选择或修改职业
       public function choosejob(){
              $user=M("User");
              $id=$_POST["userid"];
              $professionid=$_POST["professionid"];
              $newdata["user_id"]=$id;
              $newdata["profession_id"]=$professionid;
              $result=$user->save($newdata);//当数据相同时，无法修改，即为原数据     
              if ($result) {
                 $this->ajaxReturn(array("code"=>200,"message"=>"修改成功","data"=>$result[0]),"JSON");
              }else{
                   $this->ajaxReturn(array("code"=>500,"message"=>"修改失败","data"=>$data[0]),"JSON");
              }
       }
}